Skip to content

SpringAI instrumentation enhancements#49

Open
Andrew Kent (realark) wants to merge 5 commits intomainfrom
ark/springai-openai
Open

SpringAI instrumentation enhancements#49
Andrew Kent (realark) wants to merge 5 commits intomainfrom
ark/springai-openai

Conversation

@realark
Copy link
Collaborator

@realark Andrew Kent (realark) commented Mar 23, 2026

  • support springai+openai
  • support springai+anthropic

also made some changes to muzzle to better support the multi chat model stuff springai provides

@realark Andrew Kent (realark) added the enhancement New feature or request label Mar 23, 2026
@realark Andrew Kent (realark) force-pushed the ark/springai-openai branch 5 times, most recently from 7797207 to bfab183 Compare March 23, 2026 21:47
@realark Andrew Kent (realark) force-pushed the ark/springai-openai branch 3 times, most recently from e19ed25 to 089422a Compare March 23, 2026 23:34
@realark Andrew Kent (realark) marked this pull request as ready for review March 24, 2026 00:07
// -------------------------------------------------------------------------

@lombok.SneakyThrows
static void tagSpanRequest(Span span, org.springframework.ai.chat.prompt.Prompt prompt) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of duplicate logic in both the anthropic and openai wrapper, like this function tagSpanRequest. Worth DRYing up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll leave it as-is for now. I'm not sure if the similarities are more of a coincidence vs DRYable design, but I'll revisit if this pattern repeats

"https://api.anthropic.com",
List.of("v1", "messages"),
"POST",
BraintrustJsonMapper.toJson(requestBody));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the json serialization throw? lombok.SneakyThrows will just rethrow and crash the app right (never seen SneakyThrows before so unfamiliar)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it can throw. I added exception handling and debug logging to the braintrust observer to address this

import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.openai.OpenAiChatModel;

/** Braintrust Spring AI instrumentation entry point. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to update this docstring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those docstrings didn't really add much, so I just removed them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants